from api.gpt3_api import GPT3
from api.gpt4_api import GPT4
from api.kimi_api import KIMI
from api.llama3_api import LLAMA3
from api.global_config import GPT3_CONFIG, GPT4_CONFIG, KIMI_CONFIG, LLAMA3_CONFIG


def get_model_instance(model_name):
    # 初始化每个config类
    gpt3_config = GPT3_CONFIG()
    gpt4_config = GPT4_CONFIG()
    kimi_config = KIMI_CONFIG()
    llama3_config = LLAMA3_CONFIG()

    # 使用配置对象创建类的实例
    gpt3_instance = GPT3(gpt3_config)
    gpt4_instance = GPT4(gpt4_config)
    kimi_instance = KIMI(kimi_config)
    llama3_instance = LLAMA3(llama3_config)

    model_name_to_instances = {
        'gpt3': gpt3_instance,
        'gpt4': gpt4_instance,
        'kimi': kimi_instance,
        'llama3': llama3_instance,
    }
    if model_name in model_name_to_instances:
        # 获取对应的实例
        instance = model_name_to_instances[model_name]
    else:
        raise ValueError(f"No model found with the name '{model_name}'")
    return instance
